﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MarvellousWorks.PracticalPattern.Concept.Configurating
{
    /// <summary>
    /// 具有 name 和 description 属性的配置元素
    /// name 属性作为 ConfigurationElementCollection 中响应的 key
    /// </summary>
    public abstract class NamedConfigurationElementBase : ConfigurationElement
    {
        private const string NameItem = "name";
        private const string DescriptionItem = "description";

        [ConfigurationProperty(NameItem, IsKey = true, IsRequired = true)]
        public virtual string Name
        {
            get { return base[NameItem] as string; }
        }

        [ConfigurationProperty(DescriptionItem, IsRequired = false)]
        public virtual string Description
        {
            get { return base[DescriptionItem] as string; }
        }
    }
}
